package com.example.springbootbabyu.config;

/**
 * 功能
 * 作者：梦天
 * 日期：2025/6/4 9:15
 */
import com.auth0.jwt.algorithms.Algorithm;
import com.example.springbootbabyu.utils.JwtTokenUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate;

@Configuration
public class JwtConfig {

    @Value("${jwt.secret}")
    private String secret;

    @Value("${jwt.expire}")
    private long expire;

    @Bean
    public Algorithm algorithm() {
        return Algorithm.HMAC256(secret);
    }

    @Bean
    public JwtTokenUtil jwtTokenUtil(Algorithm algorithm, StringRedisTemplate redisTemplate) {
        return new JwtTokenUtil(algorithm, redisTemplate, expire);
    }
}